/*
 * Copyright 2009 BioTeam Inc
 * 
 * Licensed under License GNU LESSER GENERAL PUBLIC LICENSE version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.bioteam.appweb.model;

import junit.framework.TestCase;
import net.bioteam.appweb.TestConfig;
import net.bioteam.appweb.submit.DefaultCommandLineGenerator;
import net.bioteam.appweb.submit.ProgramValueBean;


public class BlastallTest extends TestCase {

	public void setUp() throws Exception {
		TestConfig.init();
			 BeanshellProgramModifier modifier=new BeanshellProgramModifier();
         ProgramBuilder.modifiers.add(modifier);

	}

	public void tearDown() throws Exception {
		TestConfig.shutdown();
	}
	
	public void testBlastall() throws Exception {
		Program program;
		Parameter p;
		DefaultCommandLineGenerator generator = new DefaultCommandLineGenerator();
		String cmdline, expected;
		ProgramValueBean bean;
		ProgramBuilder.cache.remove("blastall");
		

		program = ProgramBuilder.getProgram("blastall");
		bean = new ProgramValueBean(program);
		bean.setValue("nb_proc","0");
		bean.setValue("seqalign_file","");
		bean.setValue("strand","3");
		bean.setValue("Alignments","250");
		bean.setValue("Descriptions","500");
		bean.setValue("html4blast_input","");
		bean.setValue("txtoutput","");
		bean.setValue("psi_checkpoint_data","");
		bean.setValue("gapped_alig","1");
		bean.setValue("extend_hit","0");
		bean.setValue("other_filters","");
		bean.setValue("compostional_adjustment","0");
		bean.setValue("keep_hits","0");
		bean.setValue("Expect","10");
		bean.setValue("match","1");
		bean.setValue("blastall","blastp");
		bean.setValue("filter","1");
		bean.setValue("protein_db","/common/data/pir_nref_human.fa /common/data/pir_nref_mouse.fa");
		bean.setValue("query_data","");
		bean.setValue("gc_query","1");
		bean.setValue("gc_db","1");
		bean.setValue("frame_shift_penalty","0");
		bean.setValue("query","universal.log");
		bean.setValue("start_region","0");
		bean.setValue("believe","0");
		bean.setValue("extend_a_gap","0");
		bean.setValue("word_size","0");
		bean.setValue("view_alignments","0");
		bean.setValue("dropoff_extent","0.0");
		bean.setValue("hitlist","0");
		bean.setValue("external_links","1");
		bean.setValue("matrix","BLOSUM62");
		bean.setValue("dist_hits","0");
		bean.setValue("open_a_gap","0");
		bean.setValue("dropoff","0");
		bean.setValue("intron_length","0");
		bean.setValue("lower_case","0");
		bean.setValue("htmloutput","1");
		bean.setValue("image_query","0");
		bean.setValue("dropoff_final","0");
		bean.setValue("mismatch","-3");
		bean.setValue("one_HSP_per_line","0");
		bean.setValue("end_region","0");
		expected="blastall -p blastp  -d \"/common/data/pir_nref_human.fa /common/data/pir_nref_mouse.fa\" " +
				" -i universal.log  -G 0  -L \"0 0\"  -W 0  -A 0  -y 0  " +
						"-K 0  -X 0  -Z 0  -E 0  -a 2  -o blastall.txt";
		cmdline = generator.generateScript((ProgramValueBean) bean
				.myClone(), null);
		assertEquals(expected, cmdline.trim());
	}
}
